docs: generalize doc standard to all crates and config sections#83
docs: generalize doc standard to all crates and config sections#83bglusman wants to merge 4 commits into
Conversation
Adds per-channel setup docs (Telegram, Matrix, Signal, WhatsApp) to docs/channels/ as part of the public docs site (calciforge.org/channels/). Each guide covers: architecture diagram, prerequisites, config TOML, identity/routing wiring, and a verify step. The TOML config blocks in each doc are compile-tested: config.rs grows extract_toml_blocks() + test_channel_docs_<channel>_toml_blocks_valid tests that load each markdown via include_str!, extract every fenced [[channels]] block, and parse it against the live CalciforgeConfig schema. If a field is renamed and the doc isn't updated, cargo test fails. Also adds test_channel_config_<channel>_inline unit tests as schema-correct reference examples for each channel kind. AGENTS.md documents the standard and process: every channel needs a docs/channels/ entry, tests in config.rs, and both must be updated together when the schema changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Broadens the documentation standard from channels-only to a project-wide gold standard covering all user-facing config, public library APIs, and user-facing features across all crates. Key points: - Library crates (secrets-client, adversary-detector, etc.) use native Rust doctests (cargo test --doc -p <crate>) - Binary crates (calciforge, host-agent) use the include_str! + unit test pattern established for channels - Every pub struct field needs a doc comment; every TOML example in docs/ must be compile-tested - Defines the five-section structure all setup guides must follow - Table of which doc file maps to which test for each config area - Explicit rule: no new config section, channel, or public API without tested docs; PRs without docs should not be merged Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
|
| Filename | Overview |
|---|---|
| AGENTS.md | Adds comprehensive documentation standard section; example snippet uses doc_blocks_with/parse_as_config which don't exist in the codebase |
| crates/calciforge/src/config.rs | Adds test helpers (extract_toml_blocks, channel_blocks_from_doc, parse_channel_block) and 8 tests covering inline TOML and doc-file TOML blocks for all four channels; implementation is clean and correct |
| docs/channels/telegram.md | New Telegram setup guide with all five required sections; channel TOML block matches the inline test in config.rs |
| docs/channels/matrix.md | New Matrix setup guide; includes E2EE-not-supported warning, all required sections, and TOML example verified by tests |
| docs/channels/signal.md | New Signal setup guide; ZeroClaw config block correctly uses [channels_config.signal] so it isn't accidentally caught by the channel-block filter in tests |
| docs/channels/whatsapp.md | New WhatsApp setup guide; detailed webhook payload, reply API, and HMAC verification sections; TOML examples verified by tests |
| docs/index.md | Adds navigation links to the four new channel setup guides under the channels section |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["docs/channels/*.md\n(Markdown with fenced TOML blocks)"] --> B["include_str! at compile time\n(config.rs test module)"]
B --> C["extract_toml_blocks(markdown)\nreturns all fenced toml blocks"]
C --> D["channel_blocks_from_doc(markdown)\nfilters for blocks containing [[channels]]"]
D --> E["parse_channel_block(block)\nwraps in [calciforge] envelope\nand calls toml::from_str"]
E --> F{Parse OK?}
F -->|yes| G["assert cfg.channels[0].kind == expected"]
F -->|no| H["panic with block content + error\n(test fails, CI blocks merge)"]
G --> I["test passes"]
Reviews (2): Last reviewed commit: "fix(docs): fix SecretsClient example in ..." | Re-trigger Greptile
There was a problem hiding this comment.
Pull request overview
Expands Calciforge’s documentation approach by adding compile-tested channel setup guides and codifying a project-wide “tested docs” standard for user-facing config and public APIs.
Changes:
- Adds new channel setup guides under
docs/channels/(Telegram, Matrix, Signal, WhatsApp) with TOML examples intended to stay schema-correct. - Updates
crates/calciforge/src/config.rstests toinclude_str!the channel docs and parse fenced[[channels]]TOML blocks against the liveCalciforgeConfigschema. - Updates
AGENTS.mdto define the repo-wide documentation/testing standard and links channel guides fromdocs/index.md.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/index.md | Links to the new per-channel setup guides from the main docs index. |
| docs/channels/whatsapp.md | Adds a WhatsApp webhook + ZeroClaw/OpenClaw setup guide with config examples. |
| docs/channels/telegram.md | Adds a Telegram long-poll setup guide with config examples. |
| docs/channels/signal.md | Adds a Signal webhook + ZeroClaw/OpenClaw setup guide with config examples. |
| docs/channels/matrix.md | Adds a Matrix /sync long-poll setup guide (explicitly notes no E2EE) with config examples. |
| crates/calciforge/src/config.rs | Adds tests that parse channel-doc TOML blocks to prevent schema drift. |
| AGENTS.md | Documents the “tested docs” gold standard and how to implement it for crates/config sections. |
| | `homeserver` | yes | Full URL of the Matrix homeserver | | ||
| | `access_token_file` | yes | Path to file containing the bot's access token | | ||
| | `room_id` | yes | Internal room ID (starts with `!`) | | ||
| | `allowed_users` | yes | Matrix user IDs permitted to send commands; empty list allows all room members (not recommended) | |
| bot will route to the default agent. On an unknown user ID, you'll see | ||
| `no identity for telegram/<id>` — use that output to find the ID if needed. |
| /// # use secrets_client::SecretsClient; | ||
| /// let client = SecretsClient::new(); | ||
| /// let value = client.resolve("MY_API_KEY")?; |
The doctest example used secrets_client::SecretsClient which doesn't exist. The real public API is FnoxClient with an async get() method. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Closing as superseded by the current docs-test direction and #89. The integration branch includes the relevant docs expansion on top of latest main without the stale conflicts. |
Summary
Broadens the documentation standard from "channels only" to a project-wide gold standard that applies to all user-facing config, public library APIs, and user-facing features across every crate.
The two mechanisms
Library crates (
secrets-client,adversary-detector,clashd,mcp-server,paste-server,security-proxy): native Rust doctests in///comments —cargo test --doc -p <crate>compiles and runs them.Binary crates (
calciforge,host-agent):include_str!+ unit tests that load markdown files, extract fenced TOML blocks, and parse them against the live config schema. The channel tests inconfig.rsare the canonical reference implementation.What's defined
docs/agents.md,docs/routing.md,docs/model-gateway.md, etc.)What this doesn't do
Doesn't add the missing docs yet — that's the next body of work. This PR establishes the standard so any agent or contributor knows exactly what's required when they touch any part of the codebase.
Merge order
Can merge independently of PR #82 (channel setup guides) or after — the standard references the channel tests as the canonical example.
Generated with Claude Code